// ==UserScript==
// @name         Xiami.com
// @namespace    https://git.oschina.net/yjbc/userscripts
// @version      0.1
// @author       映阶碧草
// @match        https://*.xiami.com/*
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @resource     index.css index.css
// @require      style.js
// ==/UserScript==

const myWidget = document.createElement('a')
myWidget.textContent = '变身'
myWidget.classList.add('bt_choose')
myWidget.href = '#'
myWidget.addEventListener('click', selectLast50Songs)

function selectLast50Songs (event) {
    event.preventDefault()
    const songList = document.querySelectorAll('[type=checkbox]')
    songList.forEach((song, index) => {
        song.checked = index >= songList.length - 50
    })
}

document.querySelector('.ctrl_play').prepend(myWidget)
